html.homepage-featured-topics {
  #banner {
    margin-bottom: 1.5em;
  }
}

.featured-topic-wrapper {
  margin-bottom: 3em;
  text-align: center;
  border-bottom: 1px solid var(--primary-low);
  position: relative;

  @media screen and (width <= 450px) {
    margin-top: 1em;
  }

  .spinner {
    position: absolute;
    left: 0;
    right: 0;
    top: 80px;
    margin-left: auto;
    margin-right: auto;

    @media screen and (width <= 450px) {
      top: 70px;
    }
  }

  h2 {
    border-bottom: 1px solid var(--primary-low);
    padding-bottom: 0.5em;
    margin-bottom: 1.5em;
  }

  .featured-topics-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;

    .page-button-container {
      flex: 0 0 3em;
    }

    .page-button {
      height: min-content;
      padding: 0.5em;
      margin-bottom: 3em;
    }

    .left-page-button {
      margin-right: 0.4em;
    }

    .right-page-button {
      margin-left: 0.4em;
    }

    .featured-topics {
      flex: 1;
      display: flex;
      justify-content: center;
      align-items: flex-start;

      .featured-topic {
        flex: 1 1 30%;
        max-width: 500px;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: center;

        @media screen and (width >= 451px) {
          margin: 0 1.25em;

          &:first-of-type:not(:last-of-type) {
            margin-left: 0;
          }

          &:last-of-type:not(:first-of-type) {
            margin-right: 0;
          }
        }

        @media screen and (width <= 999px) {
          &:nth-of-type(4) {
            margin-right: 0;
          }

          &:nth-of-type(n + 5) {
            display: none;
          }
        }

        @media screen and (width <= 800px) {
          &:nth-of-type(3) {
            margin-right: 0;
          }

          &:nth-of-type(n + 4) {
            display: none;
          }
        }

        @media screen and (width <= 600px) {
          width: 100%;

          &:nth-of-type(2) {
            margin-right: 0;
          }

          &:nth-of-type(n + 3) {
            display: none;
          }
        }

        @media screen and (width <= 450px) {
          width: 100%;

          &:nth-of-type(n + 2) {
            display: none;
          }
        }

        h3 {
          margin: 0;
          font-size: var(--font-up-2);
          padding: 0.5em 1em 1em 1em;

          a {
            display: -webkit-box;
            overflow: hidden;
            text-overflow: ellipsis;
            word-wrap: break-word;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
          }
        }

        .featured-topic-image {
          height: 150px;
          max-width: 450px;
          width: 100%;
          background-size: cover;
          background-position: center center;

          a {
            display: block;
            width: 100%;
            height: 100%;
          }
        }
      }
    }
  }

  // same effect till max-width 600px
  &.-mobile-stacked,
  &.-mobile-horizontal {
    .featured-topics {
      justify-content: flex-start;

      @media screen and (width <= 999px) {
        flex-direction: row;
        gap: 1.25em;
        padding-bottom: 1rem; // spacing for scroll on mobile
        overflow-x: scroll;

        .featured-topic {
          flex-shrink: 0;
          margin: 0;

          &:nth-of-type(n + 5) {
            display: flex;
          }
        }
      }

      @media screen and (width <= 800px) {
        .featured-topic {
          flex-basis: 45%;

          &:nth-of-type(n + 4) {
            display: flex;
          }
        }
      }
    }
  }

  @media screen and (width <= 600px) {
    &.-mobile-stacked {
      .featured-topics {
        flex-direction: column;
        align-items: center;
        gap: 0;

        .featured-topic {
          flex-basis: 100%;
          margin: 0;

          &:nth-of-type(n + 3) {
            display: flex;
          }

          &:nth-of-type(n + 2) {
            display: flex;
          }

          h3 {
            padding-top: 0.25em;
          }
        }
      }
    }

    &.-mobile-horizontal {
      .featured-topics {
        .featured-topic {
          flex-basis: 75%;

          &:nth-of-type(n + 3) {
            display: flex;
          }

          &:nth-of-type(n + 2) {
            display: flex;
          }
        }
      }
    }
  }

  @media screen and (width <= 400px) {
    &.-mobile-horizontal {
      .featured-topics {
        .featured-topic {
          flex-basis: 85%;
        }
      }
    }
  }
}

body:not(.staff) {
  .tag-drop li[data-name="#{$featured-tag}"],
  [data-tag-name="#{$featured-tag}"] {
    display: none;
  }
}

button.featured-topic-toggle {
  gap: 0.35em;
  justify-content: flex-start;
  margin-bottom: 1.5em;

  .d-button-label + .d-icon {
    order: -1;
    margin: 0;
  }
}
